import React, { Component } from 'react'
import NavHeader from '../../components/NavHeader'
import HouseItem from '../../components/HouseItem'

import styles from "./index.module.scss"
import { API } from '../../utils/axios'
import { Toast } from 'antd-mobile'

export default class Favorate extends Component {
  state = {
    housesList: []
  }

  componentDidMount() {
    this.getHousesList();
  }
  async getHousesList() {
    const { data } = await API.get('/user/favorites');
    if (data.status !== 200) return Toast.info('拉取收藏列表失败！', 2, null, false);

    this.setState({housesList: data.body});
  }

  render() {
    return (
      <>
        <div className={styles.myHeader}>
          <NavHeader >我的收藏</NavHeader>
        </div>
        <HouseItem housesList={this.state.housesList} />
      </>
    )
  }
}
